#ifndef __BSP_IIC_H
#define __BSP_IIC_H

#include "ch32f10x.h"
#include "stdio.h"	
#include "stdbool.h"	



#define IIC_PORT	GPIOB
#define SCL_PIN		GPIO_Pin_6       
#define SDA_PIN		GPIO_Pin_7

#define SCL_H 		IIC_PORT->BSHR = SCL_PIN
#define SCL_L 		IIC_PORT->BCR = SCL_PIN
		
#define SDA_H 		IIC_PORT->BSHR = SDA_PIN
#define SDA_L 		IIC_PORT->BCR = SDA_PIN

#define SCL_read 	(IIC_PORT->INDR  & SCL_PIN)
#define SDA_read 	(IIC_PORT->INDR  & SDA_PIN)

extern uint32_t iicBaud;

void I2C_GPIO_Config(void);

bool I2C_Start(void);
bool I2C_Stop(void);
void I2C_Ack(void);
void I2C_NoAck(void);
bool I2C_WaitAck(void);
void I2C_SendByte(uint8_t SendByte);
uint8_t I2C_RadeByte(void);
bool I2C_Write_REG(uint8_t SlaveAddress,uint8_t REG_Address, uint8_t REG_data);
bool I2C_Read_REG(uint8_t SlaveAddress, uint8_t REG_Address , uint8_t *data);
bool I2C_Write_DataNaddr(uint8_t REG_Address, uint8_t data);

//void Delay_Us(uint32_t baud);

#endif
